import Vue from 'vue';
import Router from 'vue-router';

import Layout from '@/layout/index.vue';

import resumeRouter from './modules/resume';
// import nestedRouter from './modules/nested';
// import USerRouter from './modules/user';

Vue.use(Router);

export const constantRoutes = [
  {
    path: '',
    redirect: '/resume',
    hidden: false,
  },
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true,
  },
  {
    path: '/resume',
    component: () => import('@/views/resume/index'),
    hidden: true,
  },

  {
    path: '/404',
    component: () => import('@/views/errorPage/404'),
    hidden: true,
  },
  {
    path: '/401',
    component: () => import('@/views/errorPage/401'),
    hidden: true,
  },
  {
    path: '/guide',
    component: Layout,
    redirect: '/guide/index',
    children: [
      {
        path: 'index',
        component: () => import('@/views/guide/index'),
        name: 'Guide',
        meta: { title: 'guide', icon: 'guide', noCache: true },
      },
    ],
  },
];

export const asyncRoutes = [
  resumeRouter,
  // chartsRouter,
  // nestedRouter,
  // {
  //   path: '/icon',
  //   component: Layout,
  //   children: [
  //     {
  //       path: 'index',
  //       component: () => import('@/views/svgIcons/index'),
  //       name: 'Icons',
  //       meta: {
  //         title: 'icons',
  //         icon: 'icon',
  //         noCache: true,
  //         roles: ['admin', 'tourist'],
  //       },
  //     },
  //   ],
  // },
];
const createRouter = () => new Router({
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes,
});

const router = createRouter();

export function resetRouter() {
  const newRouter = createRouter();
  router.matcher = newRouter.matcher; // reset router
}

export default router;
